package com.example.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController extends BaseController {

    @RequestMapping({"", "/", "index"})
    public String index() {
        //设置 pn 默认值
        int pn = ServletRequestUtils.getIntParameter(request, "pn", 1);
        //设置 size 默认值
        int size = ServletRequestUtils.getIntParameter(request, "size", 2);
        Page page = new Page(pn,size);
        //1分页信息 2分类 3用户 4置顶  5精选 6排序
        IPage results = postService.paging(page,null,null,null,null,"created");

        request.setAttribute("pageData", results);
        request.setAttribute("currentCategoryId", 0);
        return "index";
    }

}
